package com.tutorial;

import com.db.DataBaseHelper;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class LocationList extends ListActivity {
	public static int position;
	DataBaseHelper db = new DataBaseHelper(this);
	int m;

	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.view);
		
		   setListAdapter(new ArrayAdapter<String>(this,R.layout.list,R.id.title,db.getAllData()));
	       db.close();
	}

	/* (non-Javadoc)
	 * @see android.app.ListActivity#onListItemClick(android.widget.ListView, android.view.View, int, long)
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		// TODO Auto-generated method stub
		super.onListItemClick(l, v, position, id);
		System.out.print("Position is" +position);
	
		Item.position = position;
		
		Log.v("Item"," "+getListView().getItemAtPosition(position).toString());
		String s = getListView().getItemAtPosition(position).toString();
		Intent i = new Intent(this, Item.class);
		startActivity(i);
	}
	

}
